package risk.client.gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;

import javax.swing.JPanel;

import risk.client.logic.Player;

/**
 * @author: Johan
 */
public class WinnerDialog extends JDialog {

    final int ATTACKER = 0;
    final int DEFENDER = 1;
  
    /**
     * Create dialog
     * 
     * @author: Johan
     * @param player
     */
    public WinnerDialog(Player player) {
        try {
            jbInit(player);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Init dialog
     * 
     * @author: Johan
     * @param player
     * @throws Exception
     */
    private void jbInit(Player player) throws Exception {
        
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension screenSize = tk.getScreenSize();
        int screenHeight = screenSize.height;
        int screenWidth = screenSize.width;
        this.setLocation(screenWidth / 4, screenHeight / 4);
        this.setSize(570, 275);
        this.getContentPane().setBackground(Color.BLACK);
        
        JPanel pane = new JPanel(new BorderLayout()){
          
          ImageIcon bgImage = new ImageIcon(GameBoard.IMG_PATH + "winnerDialog.png");
          public void paint(Graphics g) {
            super.paint(g);
            g.drawImage(bgImage.getImage(), 0, 0, null);
          }
        };
        setLayout(new BorderLayout());
        pane.setBackground(Color.BLACK);
        
        JLabel jLabel1 = new JLabel("\n" + player.getName() + "!", null, JLabel.CENTER);
        jLabel1.setBorder(BorderFactory.createEmptyBorder(10,10,20,10));
        jLabel1.setFont(new Font("SansSerif", Font.BOLD, 32));
        jLabel1.setForeground(Color.WHITE);
        pane.add(jLabel1, BorderLayout.SOUTH);
        this.getContentPane().add(pane, BorderLayout.CENTER);
        this.setVisible(true);
        
        return;
    }
}
